package cn.devil.two.utils

import redis.clients.jedis.{Jedis, JedisPool, JedisPoolConfig}

object JedisUtil {
  val config: JedisPoolConfig = new JedisPoolConfig
  //最大空闲数
  config.setMaxIdle(100)
  //最小空闲数
  config.setMinIdle(20)
  //每次最大的连接数
  config.setNumTestsPerEvictionRun(1024)
  //释放扫描的扫描间隔，单位毫秒数；检查一次连接池中空闲的连接,把空闲时间超过minEvictableIdleTimeMillis毫秒的连接断开，直到连接池中的连接数到minIdle为止
  config.setTimeBetweenEvictionRunsMillis(60000000)
  private lazy val pool: JedisPool = new JedisPool(config,"Devil21",6379)
  def getJedis: Jedis = pool.getResource
}
